#include "gt_list.h"

// ok
gt_list *create_list() { return NULL; }

// ok
void add_element(gt_list **list, char *elem) {
  gt_list *new_ls;
  gt_list *ptr;

  int len;

  len = strlen(elem) + 1;
  new_ls = (gt_list *)calloc(1, sizeof(gt_list) + len);

  strncpy(new_ls->data, elem, len);

  if (*list) {
    ptr = *list;
    while (ptr->next)
      ptr = ptr->next;

    ptr->next = new_ls;
  } else {
    *list = new_ls;
  }
}

// ok
void free_list(gt_list **list) {
  gt_list *ptr = *list;
  while (*list) {
    ptr = *list;
    *list = (*list)->next;
    free(ptr);
  }
}
